package com.nftturbo.base.response;

import lombok.Getter;
import lombok.Setter;

import java.io.Serial;

/**
 * TODO
 *
 * @author 11522
 * @since 2024/7/8 22:38
 **/
@Getter
@Setter
public class SingleResponse<T> extends BaseResponse {
    @Serial
    private static final long serialVersionUID = 1L;

    private T data;

    public static <T> SingleResponse<T> of(T data) {
        SingleResponse<T> singleResponse = new SingleResponse<>();
        singleResponse.setSuccess(true);
        singleResponse.setData(data);
        return singleResponse;
    }

    public static <T> SingleResponse<T> fail(String errorCode, String errorMessage) {
        SingleResponse<T> singleResponse = new SingleResponse<>();
        singleResponse.setSuccess(false);
        singleResponse.setResponseCode(errorCode);
        singleResponse.setResponseMessage(errorMessage);
        return singleResponse;
    }
}
